package com.zhangfei.sys.service.impl;

import com.zhang.entity.Cultivate;
import com.zhang.entity.Employee;
import com.zhang.entity.Evaluation;
import com.zhang.entity.Retuntity;
import com.zhangfei.cilent.IUserClient;
import com.zhangfei.sys.dao.CultivateDao;
import com.zhangfei.sys.service.CultivateService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * (Cultivate)表服务实现类
 *
 * @author makejava
 * @since 2021-06-25 09:09:44
 */
@Service("cultivateService")
public class CultivateServiceImpl implements CultivateService {
    @Resource
    private CultivateDao cultivateDao;
    

    /**
     * 通过ID查询单条数据
     *
     * @param pid 主键
     * @return 实例对象
     */
    @Override
    public Cultivate queryById(Integer pid) {
        return this.cultivateDao.queryById(pid);
    }



    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Cultivate> queryAllByLimit(int offset, int limit) {
        return this.cultivateDao.queryAllByLimit(offset, limit);
    }

    @Override
    public int insertBatch(List<Cultivate> entities) {
        return cultivateDao.insertBatch(entities);
    }

    @Override
    public Cultivate queryByUserId(Integer eid) {
        return this.cultivateDao.queryByUserId(eid);
    }

    /**
     * 新增数据
     *
     * @param cultivate 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional
    public Cultivate insert(Cultivate cultivate) {
        cultivate.setCreateTime(new Date());
        this.cultivateDao.insert(cultivate);
        return cultivate;
    }

    /**
     * 修改数据
     *
     * @param cultivate 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional
    public Cultivate update(Cultivate cultivate) {
        this.cultivateDao.update(cultivate);
        return this.queryById(cultivate.getPid());
    }

    /**
     * 通过主键删除数据
     *
     * @param pid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer pid) {
        return this.cultivateDao.deleteById(pid) > 0;
    }
}
